package indi.zhifa.recipe.bailan.framework.enums.controller.api;


import indi.zhifa.recipe.bailan.framework.common.entity.annotations.UnLogin;
import indi.zhifa.recipe.bailan.framework.enums.entity.vo.EnumVo;
import indi.zhifa.recipe.bailan.framework.enums.entity.vo.IEnumVo;
import indi.zhifa.recipe.bailan.framework.enums.service.IEnumMemoService;
import indi.zhifa.recipe.bailan.framework.common.entity.annotations.ZfRestController;
import indi.zhifa.recipe.bailan.framework.common.entity.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Description: 
 * @Copyright: Copyright (c) 2020-2028 北京华咨电力科技发展有限公司 All rights reserved.
 * @author: 褚智勇(hataksumo@163.com)
 * @date:  2022/4/15 9:18
 */
@Api(tags = "枚举接口")
@RequestMapping("/api/enums")
@Slf4j
@RequiredArgsConstructor
@ZfRestController
public class EnumApi {
    
    private final IEnumMemoService mEnumMemoService;

    @UnLogin
    @Operation(summary = "查找枚举")
    @GetMapping("/{name}")
    public IEnumVo findByName(
            @Parameter(description = "枚举名") @PathVariable(name = "name") String pName) throws ServiceException {
        IEnumVo result = mEnumMemoService.findByName(pName);
        return  result;
    }

    @UnLogin
    @Operation(summary = "查找枚举列表")
    @GetMapping("/list")
    public EnumVo[] list(){
        EnumVo[] enumDtoList = mEnumMemoService.list();
        return enumDtoList;
    }
}
